// <<<<<<< HEAD
// 管理员登录接口
const express = require('express');
const router = express.Router();
const db = require('../../db/connect');
const xzid = require('xzid')
const dayjs = require("dayjs");

router.post('/admin/editTitleInfo', (req, res) => {
    const { title,content,img,state ,id} = req.body;
    console.log(req.body)
    const now = dayjs().format('YYYY-MM-DD HH:mm:ss');
    const sql = `UPDATE manger_title SET title=?,title_time=?,title_content=?,
    title_state=?,title_img=? WHERE title_id =?;
    `;
    db(sql,[title,now,content,state,img,id] ,(err, data) => {
        console.log(data)
        if (data.affectedRows !== 0) {
           res.send({
                data,
                code:200
           })
        } else {
            res.send({
                code: 400,
                content: err,
                message: '修改失败'
            })
        }
    })
})
// =======
// 管理员登录接口
// const express = require('express');
// const router = express.Router();
// const db = require('../../db/connect');
// const xzid = require('xzid')

// router.post('/admin/editTitleInfo', (req, res) => {
//     const { title,content,img,state ,id} = req.body;
//     const now = dayjs().format('YYYY-MM-DD HH:mm:ss');
//     const sql = `UPDATE manger_title SET title=${title},title_time=${now},title_content=${content},
//     title_state=${state},title_img=${img} WHERE title_id = ${id};
//     `;
//     db(sql ,(err, data) => {
//         console.log(data)
//         if (data.affectedRows !== 0) {
//            res.send({
//                 data,
//                 code:200
//            })
//         } else {
//             res.send({
//                 code: 400,
//                 content: err,
//                 message: '修改失败'
//             })
//         }
//     })
// })
// >>>>>>> a95ea6c03868051113e2bece969d9b45ce957784
module.exports = router